From: Paul Gevers Date: Sat, 15 Nov 2025 07:32:52 +0000 (+0100) Subject: New upstream version 2.0.53 X-Git-Tag: archive/raspbian/2.0.53-2+rpi1^2~8^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=6d81f1816685287815cb3129fea7cf5a16968fc9;p=siridb-server.git New upstream version 2.0.53 --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a0e7763..88600d69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Install libcleri run: | git clone https://github.com/cesbit/libcleri.git @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update -y - sudo apt-get install -y libuv1-dev libpcre2-dev libyajl-dev valgrind + sudo apt-get install -y uuid-dev libuv1-dev libpcre2-dev libyajl-dev valgrind - name: Run tests run: | cd ./Release/ diff --git a/debian/changelog b/debian/changelog index e1dc9dd6..2c7fb5ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +siridb-server (2.0.53-0~cb1) unstable; urgency=medium + + * New upstream release + - Fixed bug with rollback after failed HTTP request for a new database + - Use heap instead of stack for translating a forward query + - Fixed reaclloc with zero bug + - Update testing files + + -- Jeroen van der Heijden Wed, 22 Oct 2025 10:04:00 +0200 + siridb-server (2.0.52-0~cb1) unstable; urgency=medium * New upstream release diff --git a/docker/Dockerfile b/docker/Dockerfile index ff7d6017..c2701d56 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM amd64/alpine:3.13 +FROM amd64/alpine RUN apk update && \ apk upgrade && \ apk add gcc make libuv-dev musl-dev pcre2-dev yajl-dev util-linux-dev linux-headers git && \ @@ -11,7 +11,7 @@ RUN apk update && \ make clean && \ make -FROM amd64/alpine:3.12.4 +FROM amd64/alpine RUN apk update && \ apk add pcre2 libuv libuuid yajl && \ mkdir -p /etc/siridb && \ diff --git a/include/siri/version.h b/include/siri/version.h index 07f5d401..d78b9822 100644 --- a/include/siri/version.h +++ b/include/siri/version.h @@ -6,7 +6,7 @@ #define SIRIDB_VERSION_MAJOR 2 #define SIRIDB_VERSION_MINOR 0 -#define SIRIDB_VERSION_PATCH 52 +#define SIRIDB_VERSION_PATCH 53 /* * Use SIRIDB_VERSION_PRE_RELEASE for alpha release versions. diff --git a/itest/Dockerfile b/itest/Dockerfile index c9ae8429..d89db60e 100644 --- a/itest/Dockerfile +++ b/itest/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 AS builder +FROM ubuntu:24.04 AS builder RUN apt-get update && \ apt-get install -y \ libcleri-dev \ @@ -13,9 +13,9 @@ COPY ./include/ ./include/ COPY ./Release/ ./Release/ RUN cd ./Release && \ make clean && \ - CFLAGS="-Werror -std=gnu89" make + CFLAGS="-Werror -std=gnu89" make all -FROM python +FROM python:3.12 RUN apt-get update && \ apt-get install -y \ valgrind \ diff --git a/itest/data_google_finance.py b/itest/data_google_finance.py index 2427dedc..f73ba9a3 100755 --- a/itest/data_google_finance.py +++ b/itest/data_google_finance.py @@ -105,7 +105,7 @@ if __name__ == '__main__': args = parser.parse_args() - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() loop.run_until_complete(print_google_finance_data( ticker=args.ticker, interval=args.interval, diff --git a/itest/siridb-random-data.py b/itest/siridb-random-data.py index c53d5339..d9a5afad 100755 --- a/itest/siridb-random-data.py +++ b/itest/siridb-random-data.py @@ -1,11 +1,9 @@ #!/usr/bin/python3 -import os import sys import argparse import asyncio import time import logging -import string import random import datetime import math @@ -86,7 +84,7 @@ class Series: }[self.kind] self.lts = self._timestamp - factor = 10**r.randint(int(self.kind == int), 9) + factor = 10**r.randint(int(self.kind is int), 9) self.random_range = ( int(r.random() * -factor), int(r.random() * factor) + 1) @@ -96,13 +94,13 @@ class Series: self.likely_equal = r.choice([0.01, 0.1, 0.2, 0.5, 0.99]) self.likely_change_sign = r.choice([0.0, 0.1, 0.25, 0.5, 0.9]) - self.as_int = wrong_type and self.kind == float and r.random() > 0.9 + self.as_int = wrong_type and self.kind is float and r.random() > 0.9 self.likely_inf = r.random() * 0.2 \ - if self.kind == float and r.random() > 0.95 else False + if self.kind is float and r.random() > 0.95 else False self.likely_nan = r.random() * 0.2 \ - if self.kind == float and r.random() > 0.95 else False + if self.kind is float and r.random() > 0.95 else False - self.gen_float = wrong_type and self.kind == int and r.random() > 0.97 + self.gen_float = wrong_type and self.kind is int and r.random() > 0.97 self.name = self._gen_name() Series._series.append(self) @@ -488,7 +486,7 @@ Home-page: https://github.com/cesbit/siridb-email-check [s.strip() for s in server.split(':')] for server in args.servers.split(',')]) - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() loop.run_until_complete(dump_data(siri, args)) total_time = time.time() - start_time diff --git a/itest/tee_server.py b/itest/tee_server.py index 77d95e3b..98263b88 100755 --- a/itest/tee_server.py +++ b/itest/tee_server.py @@ -35,5 +35,5 @@ if __name__ == '__main__': parser.add_argument("-p", "--port", type=int, default=9104) args = parser.parse_args() - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() loop.run_until_complete(main(args)) diff --git a/itest/test_compression.py b/itest/test_compression.py index 8e92db58..25dc3689 100644 --- a/itest/test_compression.py +++ b/itest/test_compression.py @@ -27,7 +27,7 @@ class TestCompression(TestBase): title = 'Test compression' GEN_POINTS = functools.partial( - gen_points, n=100, time_precision=TIME_PRECISION) + gen_points, time_precision=TIME_PRECISION) async def _test_series(self, client): diff --git a/itest/test_group.py b/itest/test_group.py index 5cb5b44c..2e35d131 100644 --- a/itest/test_group.py +++ b/itest/test_group.py @@ -170,6 +170,10 @@ class TestGroup(TestBase): await self.client0.query('count groups where series > 2'), {'groups': 2}) + self.assertEqual( + await self.client0.query('select * from * before now'), + DATA) + self.client0.close() self.client1.close() diff --git a/itest/test_http_api.py b/itest/test_http_api.py index 37282103..d801c1b4 100644 --- a/itest/test_http_api.py +++ b/itest/test_http_api.py @@ -36,7 +36,7 @@ class TestHTTPAPI(TestBase): await self.client0.connect() x = requests.get( - f'http://localhost:9020/get-version', auth=('sa', 'siri')) + 'http://localhost:9020/get-version', auth=('sa', 'siri')) self.assertEqual(x.status_code, 200) v = x.json() @@ -44,7 +44,7 @@ class TestHTTPAPI(TestBase): self.assertTrue(isinstance(v[0], str)) x = requests.post( - f'http://localhost:9020/insert/dbtest', + 'http://localhost:9020/insert/dbtest', auth=('iris', 'siri'), headers={'Content-Type': 'application/json'}) @@ -62,7 +62,7 @@ class TestHTTPAPI(TestBase): } x = requests.post( - f'http://localhost:9020/insert/dbtest', + 'http://localhost:9020/insert/dbtest', data=json.dumps(data), auth=('iris', 'siri'), headers={'Content-Type': 'application/json'} @@ -81,7 +81,7 @@ class TestHTTPAPI(TestBase): } x = requests.post( - f'http://localhost:9021/new-pool', + 'http://localhost:9021/new-pool', data=json.dumps(data), auth=('sa', 'siri'), headers={'Content-Type': 'application/json'}) @@ -94,7 +94,7 @@ class TestHTTPAPI(TestBase): data = {'data': [[1579521271, 10], [1579521573, 20]]} x = requests.post( - f'http://localhost:9020/insert/dbtest', + 'http://localhost:9020/insert/dbtest', json=data, auth=('iris', 'siri')) @@ -103,7 +103,7 @@ class TestHTTPAPI(TestBase): 'success_msg': 'Successfully inserted 2 point(s).'}) x = requests.post( - f'http://localhost:9020/query/dbtest', + 'http://localhost:9020/query/dbtest', json={'q': 'select * from "data"'}, auth=('iris', 'siri')) @@ -111,7 +111,7 @@ class TestHTTPAPI(TestBase): self.assertEqual(x.json(), data) x = requests.post( - f'http://localhost:9020/query/dbtest', + 'http://localhost:9020/query/dbtest', json={'q': 'select * from "data"', 't': 'ms'}, auth=('iris', 'siri')) @@ -123,7 +123,7 @@ class TestHTTPAPI(TestBase): self.assertEqual(x.json(), data) x = requests.post( - f'http://localhost:9020/query/dbtest', + 'http://localhost:9020/query/dbtest', data=qpack.packb({ 'q': 'select sum(1579600000) from "data"', 't': 'ms'}), @@ -136,7 +136,7 @@ class TestHTTPAPI(TestBase): {'data': [[1579600000000, 30]]}) x = requests.post( - f'http://localhost:9021/new-account', + 'http://localhost:9021/new-account', json={'account': 't', 'password': ''}, auth=('sa', 'siri')) @@ -146,7 +146,7 @@ class TestHTTPAPI(TestBase): 'service account name should have at least 2 characters'}) x = requests.post( - f'http://localhost:9021/new-account', + 'http://localhost:9021/new-account', json={'account': 'tt', 'password': 'pass'}, auth=('sa', 'siri')) @@ -163,19 +163,19 @@ class TestHTTPAPI(TestBase): auth = ('tt', 'pass') x = requests.post( - f'http://localhost:9021/new-replica', json=data, auth=auth) + 'http://localhost:9021/new-replica', json=data, auth=auth) self.assertEqual(x.status_code, 400) self.assertEqual(x.json(), { 'error_msg': "database name already exists: 'dbtest'"}) x = requests.post( - f'http://localhost:9022/new-replica', json=data, auth=auth) + 'http://localhost:9022/new-replica', json=data, auth=auth) self.assertEqual(x.status_code, 401) auth = ('sa', 'siri') x = requests.post( - f'http://localhost:9022/new-replica', json=data, auth=auth) + 'http://localhost:9022/new-replica', json=data, auth=auth) self.assertEqual(x.status_code, 400) self.assertEqual(x.json(), { @@ -185,7 +185,7 @@ class TestHTTPAPI(TestBase): data['port'] = 9000 x = requests.post( - f'http://localhost:9022/new-replica', json=data, auth=auth) + 'http://localhost:9022/new-replica', json=data, auth=auth) self.assertEqual(x.status_code, 200) self.assertEqual(x.json(), 'OK') @@ -193,7 +193,7 @@ class TestHTTPAPI(TestBase): await self.assertIsRunning(self.db, self.client0, timeout=50) x = requests.get( - f'http://localhost:9022/get-databases', auth=auth) + 'http://localhost:9022/get-databases', auth=auth) self.assertEqual(x.status_code, 200) self.assertEqual(x.json(), ['dbtest']) diff --git a/itest/testing/__init__.py b/itest/testing/__init__.py index 9ce56c32..186b634e 100644 --- a/itest/testing/__init__.py +++ b/itest/testing/__init__.py @@ -40,6 +40,6 @@ async def _run_test(test, loglevel): def run_test(test, loglevel='CRITICAL'): assert isinstance(test, TestBase) - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() cleanup() loop.run_until_complete(_run_test(test, loglevel)) diff --git a/itest/testing/server.py b/itest/testing/server.py index 63ebae54..94ca7980 100644 --- a/itest/testing/server.py +++ b/itest/testing/server.py @@ -136,15 +136,16 @@ class Server: ' -H' if self.HOLD_TERM else ''), shell=True) elif self.TERMINAL == 'xterm': - self.proc = subprocess.Popen( - 'xterm {}-title {} -geometry {} -e "{}{} --config {}"' - .format('-hold ' if self.HOLD_TERM else '', - self.name, - self.GEOMETRY, - VALGRIND if self.MEM_CHECK else '', - SIRIDBC.format(BUILDTYPE=self.BUILDTYPE), - self.cfgfile), - shell=True) + self.proc = subprocess.Popen(( + 'xterm {}-title {} -geometry {} -e "{}{} --config {} ' + '--log-colorized"' + ).format('-hold ' if self.HOLD_TERM else '', + self.name, + self.GEOMETRY, + VALGRIND if self.MEM_CHECK else '', + SIRIDBC.format(BUILDTYPE=self.BUILDTYPE), + self.cfgfile), + shell=True) elif self.TERMINAL is None: errfn = f'testdir/{self.test_title}-{self.name}-err.log' outfn = f'testdir/{self.test_title}-{self.name}-out.log' diff --git a/src/ctree/ctree.c b/src/ctree/ctree.c index 0cf8ec5f..6d876498 100644 --- a/src/ctree/ctree.c +++ b/src/ctree/ctree.c @@ -826,22 +826,31 @@ static int CT_node_resize(ct_node_t * node, uint8_t pos) uint8_t diff = node->offset - pos; uint8_t oldn = node->n; node->n += diff; - tmp = (ct_nodes_t *) realloc( - node->nodes, - node->n * sizeof(ct_nodes_t)); - if (tmp == NULL && node->n) + if (node->n == 0) { - node->n -= diff; - rc = -1; + free(node->nodes); + node->nodes = NULL; + node->offset = pos; } else { - node->nodes = tmp; - node->offset = pos; - memmove(node->nodes + diff, + tmp = (ct_nodes_t *) realloc( node->nodes, - oldn * sizeof(ct_nodes_t)); - memset(node->nodes, 0, diff * sizeof(ct_nodes_t)); + node->n * sizeof(ct_nodes_t)); + if (tmp == NULL) + { + node->n -= diff; + rc = -1; + } + else + { + node->nodes = tmp; + node->offset = pos; + memmove(node->nodes + diff, + node->nodes, + oldn * sizeof(ct_nodes_t)); + memset(node->nodes, 0, diff * sizeof(ct_nodes_t)); + } } } else if (pos >= node->offset + node->n) diff --git a/src/siri/db/aggregate.c b/src/siri/db/aggregate.c index d56fa4d2..4f39071d 100644 --- a/src/siri/db/aggregate.c +++ b/src/siri/db/aggregate.c @@ -1039,17 +1039,25 @@ static siridb_points_t * AGGREGATE_filter( if (source->len > points->len) { - dpt = (siridb_point_t *) realloc( - points->data, - points->len * sizeof(siridb_point_t)); - if (dpt == NULL && points->len) + if (points->len == 0) { - /* not critical */ - log_error("Error while re-allocating memory for points"); + free(points->data); + points->data = NULL; } else { - points->data = dpt; + dpt = (siridb_point_t *) realloc( + points->data, + points->len * sizeof(siridb_point_t)); + if (dpt == NULL) + { + /* not critical */ + log_error("Error while re-allocating memory for points"); + } + else + { + points->data = dpt; + } } } } @@ -1214,15 +1222,23 @@ static siridb_points_t * AGGREGATE_group_by( if (points->len < max_sz) { /* shrink points allocation */ - point = realloc(points->data, points->len * sizeof(siridb_point_t)); - if (point == NULL && points->len) + if (points->len == 0) { - /* not critical */ - log_error("Re-allocation points failed."); + free(points->data); + points->data = NULL; } else { - points->data = point; + point = realloc(points->data, points->len * sizeof(siridb_point_t)); + if (point == NULL) + { + /* not critical */ + log_error("Re-allocation points failed."); + } + else + { + points->data = point; + } } } /* else { assert (points->len == max_sz); } */ diff --git a/src/siri/db/points.c b/src/siri/db/points.c index d0759f55..7a882e9a 100644 --- a/src/siri/db/points.c +++ b/src/siri/db/points.c @@ -92,9 +92,17 @@ siridb_points_t * siridb_points_new(size_t size, points_tp tp) */ int siridb_points_resize(siridb_points_t * points, size_t n) { + siridb_point_t * tmp; assert( points->len <= n ); - siridb_point_t * tmp = realloc(points->data, sizeof(siridb_point_t) * n); - if (tmp == NULL && n) + if (n == 0) + { + free(points->data); + points->data = NULL; + return 0; + } + + tmp = realloc(points->data, sizeof(siridb_point_t) * n); + if (tmp == NULL) { return -1; } diff --git a/src/siri/db/query.c b/src/siri/db/query.c index 4ba392ed..fccf58a1 100644 --- a/src/siri/db/query.c +++ b/src/siri/db/query.c @@ -31,7 +31,6 @@ #define QUERY_TOO_LONG -1 -#define QUERY_MAX_LENGTH 8192 #define QUERY_EXTRA_ALLOC_SIZE 200 #define SIRIDB_FWD_SERVERS_TIMEOUT 5000 /* 5 seconds */ @@ -679,11 +678,11 @@ static int QUERY_to_packer(qp_packer_t * packer, siridb_query_t * query) if (query->flags & SIRIDB_QUERY_FLAG_REBUILD) { /* reserve 200 extra chars */ - char buffer[packer->alloc_size]; + char * buffer = malloc(packer->alloc_size); size_t size = packer->alloc_size; siridb_t * siridb = query->siridb; - rc = QUERY_rebuild( + rc = (buffer == NULL) ? -1 : QUERY_rebuild( siridb, cleri_gn(query->pr->tree->children), buffer, @@ -704,6 +703,7 @@ static int QUERY_to_packer(qp_packer_t * packer, siridb_query_t * query) (const unsigned char *) buffer, packer->alloc_size - size); } + free(buffer); } else { diff --git a/src/siri/db/series.c b/src/siri/db/series.c index ff83275e..333df8b6 100644 --- a/src/siri/db/series.c +++ b/src/siri/db/series.c @@ -628,17 +628,26 @@ void siridb_series_remove_shard( else { series->idx_len -= offset; - idx = (idx_t *) realloc( - series->idx, - series->idx_len * sizeof(idx_t)); - if (idx == NULL && series->idx_len) + if (series->idx_len == 0) { - log_error("Re-allocation failed while removing series from " - "shard index"); + free(series->idx); + series->idx = NULL; } else { - series->idx = idx; + idx = (idx_t *) realloc( + series->idx, + series->idx_len * sizeof(idx_t)); + if (idx == NULL) + { + log_error( + "Re-allocation failed while removing series from " + "shard index"); + } + else + { + series->idx = idx; + } } if (series->start >= start && series->start < end) { @@ -1403,19 +1412,27 @@ int siridb_series_optimize_shard( } /* shrink memory to the new size */ - idx = (idx_t *) realloc( - series->idx, - series->idx_len * sizeof(idx_t)); - if (idx == NULL && series->idx_len) + if (series->idx_len == 0) { - /* this is not critical since the original allocated block still - * works. - */ - log_error("Shrinking memory for one series has failed!"); + free(series->idx); + series->idx = NULL; } else { - series->idx = idx; + idx = (idx_t *) realloc( + series->idx, + series->idx_len * sizeof(idx_t)); + if (idx == NULL) + { + /* this is not critical since the original allocated block still + * works. + */ + log_error("Shrinking memory for one series has failed!"); + } + else + { + series->idx = idx; + } } } else diff --git a/src/siri/service/client.c b/src/siri/service/client.c index b35baa08..22c5583c 100644 --- a/src/siri/service/client.c +++ b/src/siri/service/client.c @@ -334,12 +334,10 @@ static void CLIENT_err( ...) { char err_msg[SIRI_MAX_SIZE_ERR_MSG]; - va_list args; va_start(args, fmt); vsnprintf(err_msg, SIRI_MAX_SIZE_ERR_MSG, fmt, args); va_end(args); - sirinet_pkg_t * package = sirinet_pkg_err( adm_client->pid, strlen(err_msg), @@ -359,7 +357,6 @@ static void CLIENT_err( } sirinet_stream_decref(siri.client); - uv_close((uv_handle_t *) &siri.timer, NULL); } diff --git a/src/siri/service/request.c b/src/siri/service/request.c index bc0fc239..1405cc1e 100644 --- a/src/siri/service/request.c +++ b/src/siri/service/request.c @@ -1001,14 +1001,19 @@ static cproto_server_t SERVICE_on_get_databases( void siri_service_request_rollback(const char * dbpath) { size_t dbpath_len = strlen(dbpath); - char dbfn[dbpath_len + max_filename_sz]; - + char * dbfn = malloc(dbpath_len + max_filename_sz + 1); + if (dbfn == NULL) + { + log_error("Roll-back creating new database has failed."); + return; + } sprintf(dbfn, "%s%s", dbpath, DB_CONF_FN); unlink(dbfn); sprintf(dbfn, "%s%s", dbpath, DB_DAT_FN); unlink(dbfn); sprintf(dbfn, "%s%s", dbpath, REINDEX_FN); unlink(dbfn); + free(dbfn); if (rmdir(dbpath)) { log_error("Roll-back creating new database has failed.");